package com.woniu.after.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniu.after.client.ReturnGoodsManageClient;
import com.woniu.after.client.param.ReturnGoodsParam;
import com.woniu.after.client.result.ReturnResultInfo;
import com.woniu.after.service.ReturnService;
import com.woniu.after.service.dto.ReturnDto;
import com.woniu.after.service.form.ReturnGoodsForm;
import com.woniu.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class ReturnGoodsManageApiImpl implements ReturnGoodsManageClient {

    @Resource
    private ReturnService returnService;

    @Override
    public Result userReturnGoods(ReturnGoodsParam returnGoodsParam) {
        log.info("用户退货:{}", returnGoodsParam);
        ReturnGoodsForm returnGoodsForm = BeanUtil.copyProperties(returnGoodsParam, ReturnGoodsForm.class);
        ReturnDto returnDto = returnService.userReturnGoods(returnGoodsForm);
        ReturnResultInfo returnResultInfo = BeanUtil.copyProperties(returnDto, ReturnResultInfo.class);
        return Result.getInstance(ReturnResultInfo.class).setMsg("退货成功").setCode(200).setData(returnResultInfo);
    }
}
